def isrun(x):
    """ 闰年判断 """
    if (x % 100 == 0 and x % 400 == 0) or (x % 100 != 0 and x % 4 == 0):
        return 1
    return 0


year, month = map(int, input().split())
if month in [1, 3, 5, 7, 8, 10, 12]:
    print(31)
elif month in [4, 6, 9, 11]:
    print(30)
else:
    if isrun(year):
        print(29)
    else:
        print(28)
